$(function () {
    let id = sessionStorage.getItem("id")
    findById(id);
});

function findById(id) {
    let result = myAjax('/user/findById', 'post', {id: id});
    showData(result);
}

function showData(data) {
    $("#userId").val(data.id);
    $("#username").val(data.username);
    $("input[name='sex'][value=" + data.sex + "]").prop("checked", true);
    $("#address").val(data.adress);
    $("#age").val(data.age);
    $("#phone").val(data.phone);
    $('#education option').filter(function(){return $(this).text()==data.education;}).attr("selected",true);
    $('#graduate option').filter(function(){return $(this).text()==data.graduate;}).attr("selected",true);
    $("#registrationTime").val(data.registrationTime);
}
function userEdit() {
 let data={
     id:$("#id").val(),
     sex: $("#sex").find("option:selected").text(),
     address:$("#address").val(),
     age:$("#age").val(),
     phone:$("#phone").val(),
     group: $("#education").find("option:selected").text(),
     group: $("#graduate").find("option:selected").text(),
     registrationTime:$("#registrationTime").val(),
 }
 let result = myAjax('/user/edit','get',data);
 if (result===1){
     alert("修改成功！！！");
 }
}
function comeback(){
    location.assign("/html/manage.html");
}